package cn.kwq.project_manger.repostitory;



import cn.kwq.project_manger.pojo.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface UserRepository extends JpaRepository<User, Long> {

    @Query(value = "INSERT INTO user (nick_name, user_name,stu_num,major,institute,grade,wyuclass,openid) \n" +
            "VALUES (:#{#u.nickName},:#{#u.userName}\n" +
            ",:#{#u.stuNum},:#{#u.major},:#{#u.institute}\n" +
            ",:#{#u.grade},:#{#u.WYUclass},:#{#u.openid})",nativeQuery = true)
    @Modifying
    void register(@Param("u")User u);

    @Query(value ="SELECT \n" +
            "  table_name \n" +
            "FROM\n" +
            "  information_schema.tables \n" +
            "WHERE table_schema = 'project_system'   \n" ,nativeQuery = true)
    List<String> findAllTable();


}
